package com.flitsneak.designpatterns.mixedpatterns.facadeandfactoryandstrategy.factory;

import com.flitsneak.designpatterns.mixedpatterns.facadeandfactoryandstrategy.enums.STRATEGY_TYPE;
import com.flitsneak.designpatterns.mixedpatterns.facadeandfactoryandstrategy.strategy.RecoverStrategy;
import lombok.extern.slf4j.Slf4j;

/**
 * @author flitsneak
 * @email flitsneak@gmail.com
 * @date 2023/1/16 10:21
 * @description 追回简单工厂
 */
@Slf4j
public class RecoverFactory {

    public static RecoverStrategy getRecoverStrategy(STRATEGY_TYPE strategyType){
        RecoverStrategy recoverStrategy = null;
        try {
            recoverStrategy = (RecoverStrategy) Class.forName(strategyType.getStrategyType()).getDeclaredConstructor().newInstance();
         }catch (Exception e){
            log.error("生成策略失败！！errMsg===>{}",e.getMessage(),e);
        }
        return recoverStrategy;
    }

}
